/* FILES REQUIRED
        <link rel="stylesheet" type="text/css" href="{{$base_url}}yui/build/fonts/fonts-min.css" />
        <link rel="stylesheet" type="text/css" href="{{$base_url}}yui/build/button/assets/skins/sam/button.css" />
        <link rel="stylesheet" type="text/css" href="{{$base_url}}yui/build/container/assets/skins/sam/container.css" />
        <script type="text/javascript" src="{{$base_url}}yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
        <script type="text/javascript" src="{{$base_url}}yui/build/element/element-beta-min.js"></script>
        <script type="text/javascript" src="{{$base_url}}yui/build/container/container-min.js"></script>
        <script type="text/javascript" src="{{$base_url}}yui/build/button/button-min.js"></script>
*/

/*
        EXAMPLE 
		var tw = new NEWGENBD.Windows;
		var pop = tw.alert('Please login','You will have to login before puschasing.',"HELP");
		pop.show();
*/

	NEWGENBD.Windows = (function(){ 
	     $T =  NEWGENBD.util;    
	     var base_conf =  { width: "300px",
	               fixedcenter: true,
	               visible: false,
	               draggable: false,
	               close: true,
	               text: "Do you want to continue?",
	               icon: YAHOO.widget.SimpleDialog.ICON_INFO,
	               constraintoviewport: true
	     }
	     
	    function getOkButtonCfg(label,isDefault,handler){
	            return   { 
	                            text:label,
	                            handler:handler, 
	                            isDefault: isDefault | false 
	                     };
	    }
	     
	    function processIcon(TYPE){
	        var ICON;
	        if     (TYPE=="ALARM")
	                 return YAHOO.widget.SimpleDialog.ICON_ALARM;
	        else if(TYPE=="CLASS")    
	                 return  YAHOO.widget.SimpleDialog.ICON_CSS_CLASSNAME;                                    
	        else if(TYPE=="CUSTOM")   
	                 return  YAHOO.widget.SimpleDialog.ICON_CSS_CLASSNAME;                                                                            
			else if(TYPE=="BLOCK")
	                 return YAHOO.widget.SimpleDialog.ICON_BLOCK;    
	        else if(TYPE=="HELP")
	                 return YAHOO.widget.SimpleDialog.ICON_HELP;                                    
	        else if(TYPE=="INFORMATION")
	                 return YAHOO.widget.SimpleDialog.ICON_INFO;  
	        else if(TYPE=="INFO")
	                 return YAHOO.widget.SimpleDialog.ICON_INFO;
	        else if(TYPE=="TIP")
	                 return YAHOO.widget.SimpleDialog.ICON_TIP;
	        else if(TYPE=="TIPS")
	                 return YAHOO.widget.SimpleDialog.ICON_TIP;
	        else if(TYPE=="WARN")
	                 return YAHOO.widget.SimpleDialog.ICON_WARN;
	        else if(TYPE=="WARNING")
	                 return YAHOO.widget.SimpleDialog.ICON_WARN;                                     
	        else
	                 return YAHOO.widget.SimpleDialog.ICON_INFO;                            
	    }
	     
	    return function(){                              
            this.alert =  function(title,text,icon,divid,action){
                var pop;        
                if(!$D.get(divid)){
                        divid = YAHOO.util.Dom.generateId();
                        div   = $T.createHTMLEl('div',divid);   
                }
                conf = $T.clone(base_conf);//@TODO : use util clone function
                conf.text    = text;
                conf.close   = false;
                conf.icon    = processIcon(icon ? icon.toUpperCase() : "INFO")  ;
                conf.modal   = true;                                    
                conf.buttons = new Array(
                                            getOkButtonCfg("Ok",true,
                                                     typeof(action)=='function' ? action :   function(){
                                                                                                           this.hide();
                                                                                                        }) 
                                            );                                      
                pop = new YAHOO.widget.SimpleDialog(divid+alert,conf);
                pop.setHeader(title);
                pop.render(divid);
                
                return pop;//@TODO this should be a terracor.container object that wraps up all methods
            },
            this.confirm = function(title,question,icon,divid,actionYes,actionNo){
                var pop;        
                if(!$D.get(divid)){
                        divid = YAHOO.util.Dom.generateId();
                        div   = $T.createHTMLEl('div',divid);   
                }
                
                conf = $T.clone(base_conf);//@TODO : use util clone function
                conf.text    = question;
                conf.close   = false;
                conf.icon    = processIcon(icon ? icon.toUpperCase() : "HELP")  ;
                conf.modal   = true;                                    
                conf.buttons = new Array(
								          getOkButtonCfg("Yes",false, function(){
                                                                                  this.hide();
                                                                                  actionYes();
                                                                                 }),
                                          getOkButtonCfg("No",false, function(){
                                                                                  this.hide();
                                                                                  actionNo();
                                                                                 }));                                    
                pop = new YAHOO.widget.SimpleDialog(divid+confirm,conf);
                pop.setHeader(title);
                pop.render(divid);
                return pop;
            }
	    }                               
	})();   
	        
	NEWGENBD.container = (function(){                       
	        
	})();
